/**
 * users.js             后台会员管理js
 *
 * @author              mashanling(msl-138@163.com)
 * @date                2011-10-17
 * @last modify         2011-10-17 by mashanling
 */

//会员管理
var ADMIN = {
    index: function() {
        var msg = Cookie.get(L.msg);
        Cookie.set(L.msg, null);
        msg && Alert(msg, true); //提示信息
    },
    add: function() {
        var form = $('#form-admin_add').submit(function() {
            //console.log($(this).serialize());
            return false;
        });
        var validator = form.validate({
            submitHandler: function() {
                form.post();
            },
            rules: {
                sa_user: 'required',
                sa_pswd: {
                    username: true,
                    required: function() {
                        return !$('#hidden-admin_id').val()
                    }
                },
                sa_pswd_confirm: {
                    required: function() {
                        return !$('#hidden-admin_id').val() || !!$('#txt-pswd').val()
                    },
                    equalTo: '#txt-pswd'
                },
                real_name: 'required',
                group_id: 'required'
            },
            messages: {
                sa_user: '请输入用户名',
                real_name: '请输入真实姓名',
                sa_pswd: {
                    required: '请输入密码'
                },
                sa_pswd_confirm: {
                    required: '请输入确认密码',
                    equalTo: '两次输入的密码不一致'
                },
                group_id: '请选择所属组'
            }
        });
        
        return false;
    }
};
